﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace DAL
{
    public class DataProvider
    {
        public static OleDbConnection KetNoi()
        {
            string sCKN = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=Data/QLSV.mdb;Persist Security Info=False";
            OleDbConnection KN= new OleDbConnection (sCKN);
            KN.Open();
            return KN;
        }
        public static void DongKetNoi(OleDbConnection KN)
        {
            KN.Close();
        }
        public static DataTable LayDuLieuDataTable(string sChuoiTruyVan, OleDbConnection KN)
        {
            OleDbDataAdapter da = new OleDbDataAdapter(sChuoiTruyVan, KN);
            DataTable dt=new DataTable();
            da.Fill(dt);
            return dt;
        }
        public static bool TruyVanKhongTraVe(string sChuoiTruyVan, OleDbConnection KN)
        {
            try
            {
                OleDbCommand cmd = new OleDbCommand(sChuoiTruyVan, KN);
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception ex)
            {
                return false;  
            }
        }


        
    }
}
